// pages/index/withdraw/withdraw.js
let network = require('../../../utils/requestManager.js')
let app = getApp();
Page({

  /**
   * 页面的初始数据 
   */
  data: {
    err_msg:"错误信息",
    yu_money:0,
    win_height: '',
    card:null,
    user_name:null,
    code:null,
    money:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    console.log(options)
    that.setData({
      win_height: app.globalData.winHeight,
      yu_money: options.all_money
    })

  },
  // 获取卡号
  bind_card:function(e){
    this.setData({
      card:e.detail.value
    })
  },

  // 获取姓名
  bind_name: function (e) {
    this.setData({
      user_name: e.detail.value
    })
  },

  // 获取code
  bind_code: function (e) {
    this.setData({
      code: e.detail.value
    })
  },

  // 获取money
  bind_money: function (e) {
    this.setData({
      money: e.detail.value
    })
  },
  

  // 点击提现
  widthdraw_money:function(){
    let that = this;
    network.postRequest('backend/pay/wx/money/refund',{
      second_password:'',
      code:that.data.code,
      money: that.data.money,
      name:that.data.user_name,
      card_number:that.data.card,
      pay_type:'card'
    },function(res){
      console.log(res)
    })
  },

  //发送验证码
  send_code:function(){
    let that = this;
    network.postRequest('backend/pay/wx/refund/captcha/send',{},function(res){
      console.log(res)
    })
  },

  //请求数据
  request_data: function () {
    let that = this;
    console.log("000")
    network.getRequest('backend/shop/v1/shop/api/seller/shop_info/money/obtain', {}, function (res) {
      console.log(res)
      wx.setStorageSync('qrcode_money', res.detail.show_url)
      that.setData({
        recharge_money: res.detail.balance / 100,
        hb_money: res.detail.bei / 100,
        discount_num: res.detail.offline_discount,
      })
    }, function (err) {
      console.log(err)
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})